﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Demo.CommonBase.View.Contracts;
using Demo.CommonBase.View.Controllers;
using Demo.Services.Services.Impl.Managers;
using Demo.Services.Contracts.DTO.Infos;
using Demo.CommonBase.Logging;
using Demo.CommonBase.Exceptions;
using System.Reflection;

namespace Demo.Services.View.Controllers
{
    public class ReportController : AbstractDemoController
    {
        protected override void ConcreteExecute(IView view, string action)
        {
            try
            {
                switch (action)
                {
                    case "Services.GetProject":
                        GetProject(view);
                        break;
                    default: break;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
        private void GetProject(IView view)
        {
            ReportManager reportManager;
            IList<ProjectReportInfo> projectList;
            try
            {
                reportManager = new ReportManager();
                projectList = reportManager.GetProject();
                view.SetValue("Projects", projectList);

            }
            catch (Exception ex)
            {
                Logger.Error(ex);
                throw new UnhandledException(MethodInfo.GetCurrentMethod(), ex);
            }
        }        
    }
}
